﻿Imports NUnit.Framework
Imports System.Data.SqlClient
Imports KumaSystem.Activities.MSSQL
Imports Microsoft.Activities.UnitTesting

<TestFixture()>
Public Class TestShrinkDatabase

    Private _connString As SqlConnectionStringBuilder
    Private _server As String = "localhost"
    Private _database As String = "test_db"
    Private _username As String = "test"
    Private _password As String = ""

    <SetUp()>
    Public Sub Setup()
        _connString = New SqlConnectionStringBuilder
        With _connString
            .DataSource = _server
            .InitialCatalog = _database
            .IntegratedSecurity = True
        End With
    End Sub

    <Test()>
    Public Sub TestExecute()

        Dim testActivity As New ShrinkDatabaseActivity With {
                                            .ConnectionStrings = _connString.ConnectionString,
                                            .DatabaseName = "TEST_DB",
                                            .TargetSize = 100
                }

        Dim wfInvoker As New WorkflowInvokerTest(testActivity)
        wfInvoker.TestActivity(New TimeSpan(0, 5, 0)) '5分の実行時間

        Assert.False(wfInvoker.OutArguments("Result") Is Nothing)

        For Each res As DataRow In DirectCast(wfInvoker.OutArguments("Result"), DataSet).Tables(0).Rows
            Console.WriteLine(res.Item(0).ToString)
        Next


    End Sub

End Class
